import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

/** vuex 模块化处理 */
const modules = {};
const context = require.context("./modules", false, /\.js$/);
context.keys().map((file) => {
  const module = context(file).default;
  const name = /(\w+)\.js$/.exec(file)[1];
  module.namespaced = true;
  modules[name] = module;
});

export default new Vuex.Store({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules,
});
